package com.company.cloud.art.modules.mgr.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.company.cloud.art.modules.api.request.ArtActQueryReq;
import com.company.cloud.art.modules.api.request.ArtActSaveReq;
import com.company.cloud.art.modules.api.request.ArtActUpdateReq;
import com.company.cloud.art.modules.api.response.ArtAct;
import com.company.cloud.art.modules.api.response.ArtActQueryResp;
import com.company.cloud.art.modules.base.entity.ActivityInfo;
import com.company.cloud.art.modules.base.entity.ActivitySignUpInfo;
import com.company.cloud.art.modules.cache.utils.ArtNoUtils;
import com.company.cloud.art.modules.mgr.service.ActActivityMgrService;
import com.company.cloud.common.asserts.ValidatorUtils;
import com.company.cloud.common.auth.annotation.Authc;
import com.company.cloud.common.auth.annotation.StaffLogc;
import com.company.cloud.common.bean.BaseResult;
import com.company.cloud.common.bean.LoginSimpleUserInfo;
import com.company.cloud.common.bean.LoginUserInfo;
import com.company.cloud.common.exception.BusinessException;
import com.company.cloud.common.log.annotation.SysLog;
import com.company.cloud.common.utils.AuthContextUtils;
import com.company.cloud.common.utils.StrSplitUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 活动管理
 */
@Authc
@RestController
@RequestMapping("/mgr/art/activity")
@Api(tags="ART_Mgr_活动管理")
public class ArtActMgrController {

    @Autowired
    private ActActivityMgrService actActivityMgrService;

    @PostMapping("/query")
    @ApiOperation(value="活动查询", response= ArtAct.class)
    public BaseResult query(@RequestBody ArtActQueryReq params) {
        ArtActQueryResp data=actActivityMgrService.actQuery(params);
        return BaseResult.ok(data);
    }

    @GetMapping("/get")
    @ApiOperation(value="活动详情",response = ArtAct.class)
    public BaseResult get(@RequestParam("activityNo")String activityNo) {
        ArtAct data= actActivityMgrService.actInfo(activityNo);
        return BaseResult.ok(data);
    }

    @PostMapping("/save")
    @ApiOperation(value="活动新增",response = BaseResult.class)
    @StaffLogc(title = "活动新增", action = "活动新增", actionAdo = "活动管理")
    public BaseResult save(@RequestBody ArtActSaveReq params) {
        LoginSimpleUserInfo userInfo= AuthContextUtils.getUser();
        params.setCompanyNo(userInfo.getCompanyNo());
        actActivityMgrService.actAdd(params,userInfo);
        return BaseResult.ok();
    }

    @PostMapping("/update")
    @ApiOperation(value="活动信息表修改",response = BaseResult.class)
    @StaffLogc(title = "活动信息表修改", action = "活动信息表修改", actionAdo = "活动管理")
    public BaseResult update(@RequestBody ArtActUpdateReq params) {
        LoginSimpleUserInfo userInfo= AuthContextUtils.getUser();
        actActivityMgrService.actUpdate(params,userInfo);
        return BaseResult.ok();
    }

    @GetMapping("/delete")
    @ApiOperation(value="活动信息表删除",response = BaseResult.class)
    @StaffLogc(title = "活动信息表删除", action = "活动信息表删除", actionAdo = "活动管理")
    public BaseResult delete(@RequestParam("activityNo")String activityNo) {
        LoginSimpleUserInfo userInfo= AuthContextUtils.getUser();
        actActivityMgrService.actDel(activityNo,userInfo);
        return BaseResult.ok();
    }



}
